package com.sxbang.bms.dao;

import com.sxbang.bms.model.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserDao {

	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into sys_user(username, password, nickname, headImgUrl, phone, telephone, email, birthday, sex, status, createTime, updateTime) values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{telephone}, #{email}, #{birthday}, #{sex}, #{status}, now(), now())")
	int save(SysUser user);

	@Select("select * from sys_user t where t.id = #{id}")
	SysUser getById(Long id);

	@Select("select * from sys_user t")
	List<SysUser> getAllUsers();

	int updateUser(SysUser user);

	@Update("update sys_user t set t.password = #{password} where t.id = #{id}")
	int changePassword(@Param("id") Long id, @Param("password") String password);

	@Delete("delete from sys_user where id = #{id}")
	int deleteUser(Long id);

	@Select("select * from sys_user t where t.username = #{username}")
	SysUser getUser(String username);

}
